import axios from 'axios';

// const apiUrl = 'http://106.37.233.66:8013/backend/api/';
const apiUrl = 'http://www.x3-clover.com/api/';


// get
function getAction(url, parameter) {
  return axios({url: url, method: 'get', params: parameter});
}

// post
export function postAction(url, parameter) {
  return axios({url: url, method: 'post', data: parameter});
}

//事件列表
const thinglList = (params) => getAction(apiUrl + 'events/all', params);

// 获取漏斗列表
const getFunnelList = (params) => getAction(apiUrl + 'funnels/funnel/list', params);

// 获取漏斗详情
const getFunnelDetail = (params) => getAction(apiUrl + 'funnels/funnel/detail', params);

// 漏斗需要展示的图表内容
const funnelReportRes = (params,appid) => postAction(apiUrl + 'funnels/report?id=' + params.id + '&bookmarkId=&async=true&timeout=10&requestId=1622357264170&appId='+appid, params);

//漏斗创建
const funnelCreate = (params) => postAction(apiUrl + 'funnels/funnel/create', params);

//漏斗修改
const changeList = (params) => postAction(apiUrl + 'funnels/funnel/update?id='+params.id, params);

//属性列表
const propertyList = (params) => getAction(apiUrl + `property/properties`, params);

//属性值查询
const valueList = (params) => getAction(apiUrl + "property/values?limit=10&fuzzyStr=&_=1622415272213:552094", params);

//漏斗分析——保存——书签
//分析书签（新建）
const bookmarkCreate = (params) => postAction(apiUrl + 'bookmarks/bookmark/create', params);

//分析书签（修改）
const bookmarkUpdate = (params) => postAction(apiUrl + 'bookmarks/bookmark/update?id=13004', params);

//分析书签（详情）
const bookmarkDetail = (params) => getAction(apiUrl + 'bookmarks/bookmark/detail?id=13004', params);



export {
  getFunnelList, //获取漏斗下拉选项列表
  //getPropertiesEvents, //获取【按 xx 条件查看】下拉菜单选项列表
  funnelReportRes, //漏斗需要展示的图表内容
  funnelCreate, //漏斗创建
  thinglList, //事件列表
  propertyList, //属性列表
  valueList,                      //属性值查询（没数据）
  changeList,                       //漏斗修改（编辑）
  getFunnelDetail, // 获取漏斗详情
  bookmarkCreate,          //分析书签（新建）
  bookmarkUpdate,           //分析书签（修改）
  bookmarkDetail            //分析书签（详情）
};
